home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / program / clpsib.zip / CLIPSIB.FRM (.txt) next >
Visual Basic Form  |  1991-11-03  |  21KB  |  444 lines

  1. Form1
  2. 0Run This Program As An EXE File For Best Results
  3. Form1
  4. Label2
  5. "Use Lists To Build A Shopping List
  6. PyramidPic
  7.     WindowPic
  8. ChessPic
  9. ChessHelpCmdBut
  10. PastryList
  11.     FruitList
  12. VegList
  13. PyramidPic
  14. MeatList
  15. PyramidPic
  16. Label1
  17. Shopping List
  18. FindPic
  19.     FindTitle
  20. FindTextBox
  21. Label3
  22. Find What:
  23. Check1
  24. Case Sensitive
  25. Check2
  26. Whole Word
  27. Command1
  28. Command2
  29. Cancel
  30. ShoppingList
  31. Label4
  32. %Drag FIND Box Around By Its Title Bar
  33. ControlhWnd
  34. BringWindowToTop
  35. hWndG
  36. SetWindowPos
  37. hWndInsertAfter
  38. wFlags
  39. GetNextWindow
  40. wFlagX
  41. IsWindowVisiblex
  42. GetActiveWindow
  43.     GetParent
  44.     SetParentC
  45.     hWndChild2
  46. hWndNewParent
  47. GetWindowLong
  48. nIndex
  49. SetWindowLong
  50.     dwNewLong
  51. WS_CLIPSIBLINGS
  52. SWP_NOSIZE
  53. SWP_NOMOVE
  54. SWP_NOZORDER
  55. SWP_NOREDRAW
  56. SWP_NOACTIVATE
  57. SWP_DRAWFRAME
  58. SWP_SHOWWINDOWi
  59. SWP_HIDEWINDOW
  60. SWP_NOCOPYBITSd
  61. SWP_NOREPOSITIONK
  62. GW_HWNDLAST
  63. GW_HWNDNEXT
  64. GW_HWNDPREV
  65. GWL_WNDPROC
  66. GWW_HINSTANCEj
  67. GWW_HWNDPARENT
  68. GWW_ID
  69.     GWL_STYLE
  70. GWL_EXSTYLE
  71. Truez
  72. Falseq
  73. XStart
  74. YStart'
  75.     OKToMove1)
  76.     OKToMove2
  77.     OKToMove3
  78.     OKToMove4y
  79.     OKToMove6
  80. WindowStack
  81. NumOfControls
  82. hWndWindowToMoveo
  83. NeedsFixing
  84. GW_HWNDFIRST
  85. GW_OWNER
  86. GW_CHILDl
  87. SetClipSibling
  88. Parentv
  89.     GetWindow
  90. SetClipSiblingBit
  91. Style
  92. WS_CLIPSIBLING
  93. Form_Clickw
  94.     Form_Loadf
  95. Form1
  96. Screen4
  97. Width
  98. Height~
  99. GetWindowsDirectoryV
  100. lpBuffer
  101. nSize
  102. WinDir
  103. ChessBmp
  104. OF_EXIST
  105. OpenFile/
  106. lpFileName
  107. lpReOpenBuff
  108. OFSTRUCT
  109. wStyle
  110. Buffer
  111. ChessPicH
  112. Picture
  113. MousePointer
  114. ChessPic_Click
  115. ChessPic_MouseDownV
  116. Button
  117. Shift
  118. OkToMoveChessPic
  119. ChessPic_MouseMove
  120. ChessHelpCmdBut
  121. Visible
  122. FormParenti
  123. ControlParent
  124. ParentType
  125. AnyControl
  126. NestedSibling
  127. SetClipSiblingBits^
  128. hWndParentj
  129.     WindowPic
  130. Picture2_Click
  131. Picture2_MouseDownE
  132. OkToMovePicture2
  133. Picture2_MouseMove
  134. Picture2
  135. Command1
  136. WindowPic_Click
  137. ChessHelpCmdBut_Click
  138. List1_Click?
  139. VegList
  140. MeatListz
  141.     FruitList
  142. PastryList
  143. TopListBoxU
  144. PrecedingListBox
  145. MeatList_Click
  146. MeatList_GotFocus
  147. FruitList_Click0
  148. FruitList_GotFocus
  149. PastryList_Click
  150. VegList_Click
  151. VegList_GotFocus
  152.     FillLists
  153. PastryList_GotFocus
  154. ClickedToGetFocus
  155. ShoppingList
  156.     ListIndex
  157. BringToTop
  158. ThisList
  159. InsertAfter
  160. ClickedToSetFocus
  161. OkToMoveWindowPic
  162. GetWindowNext
  163. PyramidBmp:    
  164. PyramidPic
  165. Pyramid
  166. PyramidPic_Click
  167. Index
  168. PyramidPic_MouseDown
  169. Pic4'    
  170. OkToMovePyramidPicQ    
  171. PyramidPic_MouseMove
  172. Label3_Click\    
  173. FindLabel_Clicko    
  174. FindLabel_MouseDown
  175. OkToMoveFindPic
  176. FindLabel_MouseMove
  177. FindPic
  178. FindTitle_Click
  179. FindTitle_MouseDown
  180. FindTitle_MouseMove
  181. Timer1_Timer
  182. hwndFindPic
  183. Timer1
  184. Enabled
  185. Purpose
  186. program
  187. demonstrate
  188. Command1_Click
  189.  CLPSIB.BAS Rev. 1.0
  190.  Keith Funk (CIS 72240, 2020)7
  191.  Nov. 3, 1991 
  192.    Many thanks to Daniel Appleman (Desaware) for explainingg
  193.    the Win3 WS_CLIPSIBLINGS style without which this program
  194.    could not have been written. I'd also like to thank
  195.    Ted Young and Jonathan Zuk for the help they have given
  196.    me in learning the Win3 API.o
  197.    The purpose of the program is to demonstrate how to
  198.    implement overlapping controls in a VB program.
  199.    NOTE that the Form and all controls have their ScaleMode sett
  200.    to PIXELS. Also, AutoRedraw is False for all controls. Thee
  201.    Picture Controls that contain the bitmaps PYRAMID.BMP
  202.    and CHESS.BMP have AutoSize set to True. No other control
  203.    properties have any particular relevance for this demo.
  204.    The program is FREEWARE. Feel free to use any part of
  205.    it in your own programs. Feedback and comments wouldd
  206.    be appreciated. Have fun.
  207. -- Declarations for external functions.
  208.    CTLHWND.DLL is a custom DLL written by Jonathan Zuk. It
  209.    is included, with thanks to Jonathan, as part of CLPSIB.
  210. ctlhwnd.dll
  211. KernelZ
  212. Kernel
  213. -- Window style.
  214. -- THE SECRET TO SUCCESS<g>a
  215. -- SetWindowPos Flags
  216. -- GetWindow() Constants
  217. -- Window field offsets for GetWindowLong() and GetWindowWord()e
  218. -- OpenFile action..
  219. -- The mouse location when the mouse button is initially pressed.C
  220. -- Flags to indicate when a picture can be moved. A move
  221.    is not allowed while a DoEvents is in progress.
  222. -- Keeps track of the location of the list boxes in them
  223.    window stack.
  224. -- Flag to determine if user clicked a listbox to make
  225.    a selection or just to bring it to the front.
  226. SetClipSiblingBit
  227.    This routine sets the WS_CLIPSIBLINGS style bit for
  228.    all child windows of the Parent window *and* anyi
  229.    child windows of the child windows. The routine iss
  230.    recursive..
  231.    *** THIS IS THE KEY ROUTINE OF THE PROGRAM. ***
  232.    Setting the WS_CLIPSIBLINGS style bit is all that is-
  233.    needed to make VB work properly with overlappingg
  234.    controls. Or at least, so it appears to me.
  235. -- Get the first child window.
  236. -- Set the CLIPSIBLING bit for each child window.n
  237.    Loop terminates when GetWindowNext runs out ofu
  238.    child windows and returns NULL.
  239. -- Get current style.y
  240. -- Set the bit.e
  241. -- Set new style.,
  242. -- Process any child windows of this window.
  243. -- recursive call.
  244. -- Get the next top level child window.y
  245. Form_Load
  246. -- Display hourglass mousepointer.
  247. -- Show the window centered on the screen.
  248. *   THIS IS THE KEY TO THE ENTIRE DEMO. TRY COMMENTING OUT
  249. *   THE CALL TO SetClipSiblings AND WATCH THE PROGRAM FALL TO PIECES.*
  250. D* **
  251. -- Set the CLIPSIBLING Style bit for all child windows.d
  252.  SET UP THE CHESS.BMP CONTROLS.R
  253. -- Find the Win3 directory and append a backslash.
  254. Can't Find Window's Directory"
  255. Fatal Error"
  256. -- Strip trailing \0.
  257. -- If CHESS.BMP exists, load it into ChessPic.
  258. CHESS.BMP"
  259. Sorry, This Program Requires The Win3 Bitmap CHESS.BMP."
  260. FATAL ERROR"
  261. -- Put the Command Button for CHESS.BMP on top of the
  262.    Chess Picture, so the picture can be scrolled
  263.    underneath it. 
  264. -- If PYRAMID.BMP exists, load it into the three PyramidPic controls.A
  265. PYRAMID.BMP"
  266. Sorry, This Program Requires The Win3 Bitmap PYRAMID.BMP."
  267. FATAL ERROR"
  268. -- Make sure the PyramidPics are higher in the window stack than
  269.    WindowPic so they will appear on top of CHESS.BMP.-
  270. -- Display the Chess demo controls.W
  271.    SET UP THE LIST BOX CONTROLS.
  272. -- Add items to the lists.
  273. -- Place the controls in their correct order. 
  274.    Meat, Veg, Fruit then Pastry.
  275. -- Display them.
  276. -- improves the way Win3 initially paints the display.
  277. -- Set Global variables to keep track of which listbox
  278.    is on top and which list it normally comes after.
  279.    SET UP THE FIND CONTROLS.
  280. -- Make the Find "dialog box" the top most child
  281.    window of the Form, so it is *always* displayed on top of
  282.    all other child windows. Then make it visible.i
  283. -- improves the way Win3 initally paints the screen.
  284. -- Set standard mousepointer.n
  285. ChessPic_MouseDown
  286.    This control is filled with the bitmap CHESS.BMPP
  287.    during the Form1_Load Event. Because its AutoSize
  288.    Property is set to True, it becomes much larger thann
  289.    the WindowPic control on which it is placed, but youu
  290.    can only see the area of CHESS.BMP that is within
  291.    the boundaries of WindowPic. However, you can use yourr
  292.    mouse to -move- different parts of CHESS.BMP into the
  293.    visible area. NOTE how the picture -slides under- the
  294.    Help Command Button. Too neat.<g>
  295.    This is where the moving of CHESS.BMP begins. It is
  296.    continued in the MouseMove Event.
  297. -- Save mouse X/Y so MouseMove can determine how far
  298.    the mouse has moved.o
  299. -- Set flag for MouseMove.
  300. ChessPic_MouseMove
  301.    This is the routine that actually moves CHESS.BMP..
  302.    Note that the flag OkToMoveChessPic and the DoEventss
  303.    are *absolutely* essential to the correct operation
  304.    of this routine..
  305. -- Only move the picture if left button is down.
  306. -- Only move the picture if no DoEvent is in progress.
  307. -- DoEvents has finished.
  308. WindowPic_Click
  309.    This control is the Parent of the ChessPic control.
  310.    That is, ChessPic has been placed *on* this control,,
  311.    *not* on Form1. It serves as a clipping window whichh
  312.    restricts the amount of ChessPic which is visible..
  313.    NOTE that ChessPic has its AutoSize Property set to
  314.    True, so when CHESS.BMP is loaded into its Picturee
  315.    Property, ChessPic becomes *much* larger than thiss
  316.    picture control..
  317. ChessHelpCmdBut_Click
  318.    The main purpose of this control is to demonstratee
  319.    how setting the WS_CLIPSIBLINGS style bit allows youu
  320.    to slide a picture underneath another control. NOTE
  321.    that this control has been placed on the WindowPicc
  322.    control. It is *not* on Form1..
  323. Use the LEFT Mouse Button to drag the small pictures on top of CHESS.BMP and to scroll CHESS.BMP."
  324. Chess Help
  325. MeatList_GotFocus
  326.    Displays this list on top of the other list boxes.-
  327. FruitList_GotFocus
  328.    Displays this list on top of the other list boxes..
  329. VegList_GotFocus
  330.    Displays this list on top of the other list boxes.-
  331. FillLists
  332.    Fills the meat, vegetable, fruit and pastry lists with goodies.
  333. -- Fill the Meat List.
  334. Rib Roast"
  335. Pork Chops
  336. Chicken"
  337. Ground Beef"
  338. Lamb Chops
  339. Spare Ribs
  340. Pigs Feet"
  341. Sausage"
  342. Hot Dogs
  343. -- Fill the Vegetable List.
  344. Potatoes
  345. Onions
  346. Turnip
  347. Carrots"
  348. Beans"
  349. Eggplant
  350. Celery
  351. -- Fill the Fruit List
  352. Apples
  353. Oranges"
  354. Pears"
  355. Grapes
  356. Melons
  357. Lemons
  358. Limes"
  359. Apricots
  360. Quinces"
  361. Plums"
  362. Peaches"
  363. -- Fill the Pastry List 
  364. Donuts
  365. Bread"
  366. Crullers
  367. Cherry Pie
  368. Lemon Cake
  369. Cookies"
  370. Macaroons"
  371. Muffins"
  372. Brownies
  373. Date Squares
  374. Peach Pie"
  375. PastryList_GotFocus
  376.    Displays this list on top of the other list boxes.-
  377. MeatList_Click
  378.    Adds the item selected from MeatList to the ShoppingList.
  379. -- Don't do anything if user just clicked to bring
  380.    the list to the front.s
  381. -- Add selected item to our shopping list.
  382. FruitList_Click
  383.    Adds the item selected from FruitList to the ShoppingList..
  384. -- Don't do anything if user just clicked to bring
  385.    the list to the front.r
  386. -- Add selected item to our shopping list.
  387. PastryList_Click
  388.    Adds the item selected from PastryList to the ShoppingList.
  389. -- Don't do anything if user just clicked to bring
  390.    the list to the front.s
  391. -- Add selected item to our shopping list.
  392. VegList_Click
  393.    Adds the item selected from VegList to the ShoppingList.-
  394. -- Don't do anything if user just clicked to bring
  395.    the list to the front.s
  396. -- Add selected item to our shopping list.
  397. BringToTop
  398.    This routine brings ThisList to the top of the window
  399.    stack so it appears on top of the other listboxes..
  400.    It also sets some global variables that keep track of
  401.    the current order of the window stack..
  402. -- If ThisList is already at the top then there's nothing to do.
  403. -- Put the listbox that is currently on top back in its proper location.
  404.    Note that we don't need to specify x,y,cx and cy because the flagsf
  405.    SWP_NOMOVE and SWP_NOSIZE tell Win3 to ignore these values.
  406. -- Find out which window precedes ThisList in the window stack.t
  407. -- Move this listbox to the front of the group ofu
  408.    listboxes *BUT* behind the FindPic control. We aree
  409.    demonstrating how a control (FindPic) can *always*w
  410.    remain in front of all other controls even when
  411.    these controls are being re-arranged.
  412. -- Tell Click Event to ignore this click because
  413.    user is just bringing the list to the front.e
  414. PyramidPic_MouseDown
  415.    This is where the start of moving the small picture controls containing
  416.    PYRAMID.BMP begins.
  417. -- Save mouse X/Y so MouseMove can determine how far
  418.    the mouse has moved.u
  419. -- Set flag for MouseMove.
  420. PyramidPic_MouseMove
  421.    This is the routine that actually moves the picture controls that
  422.    contain PYRAMID.BMP..
  423. -- Only move the picture if the left mouse button is down.
  424. -- Only move the picture if no DoEvent is in progress.
  425. -- DoEvents has finished.
  426. FindTitle_MouseDown
  427.    This Picture Control acts as a dark blue title bar for the FindPicc
  428.    Picture Control. Its purpose is to allow FindPic and all its childd
  429.    windows to be dragged around the Form..
  430.    NOTE: That FindPic *always* appears on top of any other control..
  431.    Very desireable for a Find Dialog Box..
  432. -- Save mouse X/Y so MouseMove can determine how far
  433.    the mouse has moved.u
  434. -- Set flag for MouseMove.
  435. FindTitle_MouseMove
  436.    This is the routine that actually drags FindPic around.
  437. -- Only move the picture if left button is down.
  438. -- Only move the picture if no DoEvent is in progress.
  439. -- DoEvents has finished.    
  440. Command1_Click
  441.    In a -real- program, this button would activate the
  442.    code to find text..
  443. You Actually Expected Something To Happen?<g>"
  444.